package com.example.demo.service.impl;

import com.example.demo.dao.ProductRepository;
import com.example.demo.model.entity.ProductModel;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class ProductService {

    @Resource
    ProductRepository productRepository;

    public Page<ProductModel> getProductPage(Specification specification, Pageable pageable) {
        return productRepository.findAll(specification, pageable);
    }

    public ProductModel save(ProductModel model) {
        return productRepository.save(model);
    }


    public void delete(String produceId) {
        productRepository.delete(produceId);
    }


    public ProductModel getByQrcode(String getByQrcode) {
        return productRepository.findByProductQrcode(getByQrcode);
    }

    public ProductModel getById(String produceId) {
        return productRepository.findOne(produceId);
    }


}
